<?php
$r = new redis;
try {
    $r->connect('localhost', 6379, 1);
    $r->auth('123456');
    //$server_info = $r->info();
    //echo '<pre>';
    //print_r($server_info);
    $r->set('name', 'lisi');
    $r->set('age', 22, ['EX' => 5]); //设置5秒数据age 22

    echo $r->get('name');
} catch (RedisException $e) {
    echo $e->getMessage();
} finally {
    $r->close();
}
